import { QueryClient, useMutation } from "@tanstack/react-query";
import { useForm } from "react-hook-form";
import { userControllerSetRole } from "@/shared/api/api.user";
import { AxiosError } from "axios";
import { DisciplineService } from "@/shared/api/api.discipline";

export function useRemoveDiscipline() {
    const queryClient = new QueryClient

    const removeDisciplineMutation = useMutation(
        {
            mutationFn: DisciplineService.remove,
            onError: (error: (AxiosError<{ message: string }>)) => error,
        }, queryClient
    );
    const errorMessage = removeDisciplineMutation.error?.response?.data.message ;

    return {
        errorMessage,
        isSuccess: removeDisciplineMutation.isSuccess,
        handleMutate: (id:number) => removeDisciplineMutation.mutate(id),
    };
}